package com.hu.zhcc.shiro.service.Responsitory;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.dao.RDietaryMapper;
import com.hu.zhcc.shiro.entity.Reponsitory.RDietary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class DietaryServicImpl implements DietaryService {

    @Autowired
    private RDietaryMapper dietaryMapper;

    @Override
    public Page<RDietary> selectTaryAll(Map<String, String> map, RDietary dietary) {
        Integer offset = Integer.valueOf(map.get("offset"));
        Integer limit = Integer.valueOf(map.get("limit"));
        PageHelper.startPage(offset, limit);
        List<RDietary> dietaryList = dietaryMapper.selectTaryAll(dietary);
        PageInfo<RDietary> rDietaryPageInfo = new PageInfo<>(dietaryList);
        return new Page<RDietary>(rDietaryPageInfo.getTotal(), dietaryList);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return dietaryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(RDietary record) {
        return dietaryMapper.insertSelective(record);
    }

    @Override
    public RDietary taryBeforeUpdateById(int id) {
        return dietaryMapper.taryBeforeUpdateById(id);
    }

    @Override
    public int updateByPrimaryKeySelective(RDietary record) {
        return dietaryMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<RDietary> findDietaryListNameAll() {
        return dietaryMapper.findDietaryListNameAll();
    }
}
